<?php

namespace app\admin\model;

use think\Model;


class Order extends Model
{

    

    

    // 表名
    protected $name = 'order';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = false;

    // 定义时间戳字段名
    protected $createTime = false;
    protected $updateTime = false;
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
        'is_commented_text'
    ];
    

    
    public function getIsCommentedList()
    {
        return ['0' => __('Is_commented 0'), '1' => __('Is_commented 1')];
    }


    public function getIsCommentedTextAttr($value, $data)
    {
        $value = $value ?: ($data['is_commented'] ?? '');
        $list = $this->getIsCommentedList();
        return $list[$value] ?? '';
    }




    public function food()
    {
        return $this->belongsTo('Food', 'food_id', 'id', [], 'LEFT')->setEagerlyType(0);
    }
}
